package com.ikaros.utils;

import com.ikaros.model.entity.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * Created by Ikaros on 2017/9/28.
 */
public class ShiroUtil {
    /**
     * 获取Admin用户
     *
     * @return SysAdminEntity
     */
    public static SysUser getAdminEntity() {
        return (SysUser) SecurityUtils.getSubject().getPrincipal();
    }
    /**
     * 获取Admin用户ID
     *
     * @return Admin用户ID
     */
    public static Long getUserId() {
        return getAdminEntity().getUserId();
    }
    /**
     * 获取是否已登录
     * @return boolean
     */
    public static boolean isLogin() {
        return SecurityUtils.getSubject().getPrincipal() != null;
    }
}
